package com.hz.us.controller;

import com.hz.api.model.dto.TeacherDTO;
import com.hz.api.model.request.ApiResponse;
import com.hz.us.service.TeacherService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class TeacherController {

    @Resource
    TeacherService teacherService;

    @GetMapping("/all-teachers")
    public String allTeachers() {
        return ApiResponse.ok(teacherService.allTeachers());
    }

    @GetMapping("/teacher-info")
    public String getTeacherInfo(@RequestParam("teacherId") Integer teacherId) {
        TeacherDTO teacherDTO = teacherService.getTeacherById(teacherId);
        return teacherDTO == null ? ApiResponse.resNotFound() : ApiResponse.ok(teacherDTO);
    }

}
